﻿namespace Cos.Module.Media.NHibernate.Test
{
    using FluentNHibernate;
    using FluentNHibernate.Cfg;
    using FluentNHibernate.Cfg.Db;

    using global::NHibernate;

    using NUnit.Framework;

    public class FixtureBase
    {
        protected SessionSource SessionSource { get; set; }

        protected ISession Session { get; private set; }

        [TestFixtureSetUp]
        public void SetupContext()
        {
            var cfg = Fluently.Configure()
                .Database(SQLiteConfiguration.Standard.ShowSql().InMemory);
            SessionSource = new SessionSource(cfg.BuildConfiguration().Properties, new TestModel());
            this.Session = this.SessionSource.CreateSession();
            this.SessionSource.BuildSchema(this.Session);
        }

        [TestFixtureTearDown]
        public void TearDownContext()
        {
            this.Session.Close();
            this.Session.Dispose();
        }
    }
}
